package org.naivecoders.ai.functions;

import org.naivecoders.ai.types.MaybeBowl;

public class ListAppendHeadFunction extends AbstractFunction {

	@Override
	public MaybeBowl evaluate() {
		MaybeBowl f2 = getInput(1).evaluate();
		MaybeBowl f1 = getInput(0).evaluate();
		if (f1.isNothing() || f1.get().getSize() == 0) {
			return f2;
		}
		if (f2.isNothing() || f2.get().getSize() == 0) {
			return f1;
		}
		return MaybeBowl.newBowl(f2.get().append(f1.get()));
	}

}
